package com.kun.portal.webframe.util.eventQuene;

import com.lmax.disruptor.EventTranslatorOneArg;
import com.lmax.disruptor.RingBuffer;
public class MessageEventProducerWithTranslator
{
    private final RingBuffer<MessageEvent> ringBuffer;

    public MessageEventProducerWithTranslator(RingBuffer<MessageEvent> ringBuffer)
    {
        this.ringBuffer = ringBuffer;
    }

    private static final EventTranslatorOneArg<MessageEvent, Message> TRANSLATOR =
            new EventTranslatorOneArg<MessageEvent, Message>()
            {
                public void translateTo(MessageEvent event, long sequence, Message message)
                {
                    event.set(message);
                }
            };

    public void onData(Message message)
    {
        ringBuffer.publishEvent(TRANSLATOR, message);
    }
}